<style>
    .modal-content{height:460px;}
</style>
<div class="col-lg-12" style="margin-left: 10px;width: 500px; height: auto; margin-top:20px;">
    <form id="AppFormEdit" action="{:url('dlc/menu/menuedit')}" method="post" class="form-horizontal" data-bv-message="" data-bv-feedbackicons-valid="glyphicon glyphicon-ok" data-bv-feedbackicons-invalid="glyphicon glyphicon-remove" data-bv-feedbackicons-validating="glyphicon glyphicon-refresh">
        <div class="form-group">
            <input type="hidden" class="form-control" id="menu_id" type="text" name="id" value="{$parent.id}" />
            <label class="col-lg-3 control-label">菜单上级 :<sup>*</sup></label>
            <div class="col-lg-9">
                <select name="menu_pid" id="menu_pid" class="form-control">
                    <option value="0">一级菜单</option>
                    {volist name="roleList" id="vo"}
                    {eq name="vo.id" value="$parent.menu_pid"}
                    <option value="{$vo.id}" selected="selected">{$vo.name}</option>
                    {else/}
                    <option value="{$vo.id}">{$vo.name}</option>
                    {/eq}
                    {/volist}
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-lg-3 control-label">菜单名称 :<sup>*</sup></label>
            <div class="col-lg-9">
                <input class="form-control" id="name" type="text" name="name" placeholder="菜单名" value="{$parent.name}" data-bv-notempty/>
            </div>
        </div>
        <div class="form-group">
            <label class="col-lg-3 control-label">控制器/方法 :<sup>*</sup></label>
            <div class="col-lg-9">
                <input class="form-control" id="url" type="text" name="url" placeholder="控制器/方法" value="{$parent.url}" data-bv-notempty />
            </div>
        </div>

        <div class="form-group" {if condition="$parent.menu_pid eq 0"}style = "display:"{else/} style="display:none"{/if} id="parentIcon">
        <label class="col-lg-3 control-label">菜单图标 :</label>
        <div class="col-lg-9">
            <input class="form-control" type="text" name="icon" placeholder="导航栏小图标 如Home" value="{$parent.icon}">
        </div>
</div>

<div class="form-group">
    <label class="col-lg-3 control-label">菜单排序 :</label>
    <div class="col-lg-9">
        <input class="form-control" id="menu_order" type="text" name="menu_order" placeholder="排序"value="{$parent.menu_order}" />
    </div>
</div>
<div class="form-group">
    <div class="col-lg-offset-2 col-lg-4">
        <button id="pre1" style="margin-top: 5px;" class="btn btn-primary" type="submit">保存</button>
        &nbsp;&nbsp;&nbsp;&nbsp;
        <button id="del1" style="margin-top: 5px;" onclick="menuDel();" class="btn btn-danger">删除</button>
    </div>
</div>
</form>
</div>
<script type="text/javascript">
    $(function(){
        $("#parent_id").change(function(){
            var value = $(this).val();
            if(value == 0){
                $("#parentIcon").show();
            }else{
                $("#parentIcon").hide();
            }
        });
    });

    $('#AppFormEdit').bootstrapValidator({
        submitHandler: function(validator, form, submitButton) {
            var formNode = validator.$form.context;
            var tourl = formNode.action;
            var data = $(formNode).serialize();

            $.post(tourl, data, function(data) {
                if (data.code == 1) {
                    $.App.alert('success', data.msg);
                    $('.close').click();
                    $('#refresh-toggler').click();
                } else {
                    $.App.alert('danger', data.msg);
                }
            })
        }
    });

    function menuDel() {

        if(confirm("确定要删除吗？")) {
            var menu_id = $('#menu_id').val();
            $.post('/dlc/menu/menuDel', {
                id: menu_id
            }, function(data) {
                if (data.code == 1) {
                    $.App.alert('success', data.msg);
                    $('.close').click();
                    $('#refresh-toggler').click();
                } else {
                    $.App.alert('danger', data.msg);
                }
            }).complete(function() {
                $('#pre1').removeAttr('disabled');////让保存能点击
            });
        } else {
            //让保存能点击
            setTimeout(function () {
                $('#pre1').removeAttr('disabled');
            },50);
        }
    }
</script>